package com.nts.visionworks.business.application.domain;

// Generated 2013. 6. 23 ���� 6:33:40 by Hibernate Tools 4.0.0

import com.nts.visionworks.business.endpoint.domain.EndPoint;
import com.nts.visionworks.business.schedule.domain.Schedule;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.codehaus.jackson.annotate.JsonIgnore;

/**
 * ServiceChannel generated by hbm2java
 */
@Entity
@Table(name = "service_channel", catalog = "visionworks")
public class ServiceChannel implements java.io.Serializable
{

	private Long channelId;
	private ServiceApplication serviceApplication;
	private int channelNumber;
	private String channelName;
	private Set<EndPoint> endPoints = new HashSet<EndPoint>(0);
	private Set<Schedule> schedules = new HashSet<Schedule>(0);

	public ServiceChannel()
	{
	}

	public ServiceChannel(ServiceApplication serviceApplication,
			int channelNumber, String channelName)
	{
		this.serviceApplication = serviceApplication;
		this.channelNumber = channelNumber;
		this.channelName = channelName;
	}

	public ServiceChannel(ServiceApplication serviceApplication,
			int channelNumber, String channelName, Set<EndPoint> endPoints,
			Set<Schedule> schedules)
	{
		this.serviceApplication = serviceApplication;
		this.channelNumber = channelNumber;
		this.channelName = channelName;
		this.endPoints = endPoints;
		this.schedules = schedules;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "ChannelId", unique = true, nullable = false)
	public Long getChannelId()
	{
		return this.channelId;
	}

	public void setChannelId(Long channelId)
	{
		this.channelId = channelId;
	}

	@NotNull(message = "validation.serviceChannel.serviceApplication.notNull")
	@JsonIgnore
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ApplicationId", nullable = false)
	public ServiceApplication getServiceApplication()
	{
		return this.serviceApplication;
	}

	public void setServiceApplication(ServiceApplication serviceApplication)
	{
		this.serviceApplication = serviceApplication;
	}
	
	@Min(message = "validation.serviceChannel.channelNumber.min", value = 1)
	@Column(name = "ChannelNumber", nullable = false)
	public int getChannelNumber()
	{
		return this.channelNumber;
	}

	public void setChannelNumber(int channelNumber)
	{
		this.channelNumber = channelNumber;
	}

	@NotNull(message = "validation.serviceChannel.channelName.notNull")
	@Size(message = "validation.serviceChannel.channelName.length", max = 30, min = 1)
	@Column(name = "ChannelName", nullable = false, length = 30)
	public String getChannelName()
	{
		return this.channelName;
	}

	public void setChannelName(String channelName)
	{
		this.channelName = channelName;
	}

	@JsonIgnore
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "serviceChannel")
	public Set<EndPoint> getEndPoints()
	{
		return this.endPoints;
	}

	public void setEndPoints(Set<EndPoint> endPoints)
	{
		this.endPoints = endPoints;
	}

	@JsonIgnore
	@ManyToMany(fetch = FetchType.LAZY, mappedBy = "serviceChannels")
	public Set<Schedule> getSchedules()
	{
		return this.schedules;
	}

	public void setSchedules(Set<Schedule> schedules)
	{
		this.schedules = schedules;
	}

}
